package com.hongxun.design.acceptance.adapter;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.hongxun.design.R;
import com.hongxun.design.acceptance.mode.problemExist;
import com.hongxun.design.jungong.adapter.myBaseAdapter;
import com.hongxun.design.utils.TimeUtil;

import java.util.List;

/**
 * Created by cqcqwu on 2018/03/23.
 */

public class PAFLvAdapter extends myBaseAdapter<problemExist> {

    public PAFLvAdapter(Activity activity, List<problemExist> problemExists) {
        super(activity, problemExists);
    }

    @Override
    public View getV(int position, View convertView, problemExist obj) {
        ViewHolder holder;
        if (null == convertView) {
            convertView = inflater.inflate(R.layout.listview_item_paf, null);
            holder = new ViewHolder(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.setData(obj);
        return convertView;
    }

    class ViewHolder {
        private TextView tv1, tv2, tv3, tv4;

        ViewHolder(View convertView) {
            findViewByID(convertView);
            convertView.setTag(this);
        }

        private void findViewByID(View view) {
            tv1 = (TextView) view.findViewById(R.id.tv1_name_paf);
            tv2 = (TextView) view.findViewById(R.id.tv2_disc_paf);
            tv3 = (TextView) view.findViewById(R.id.tv3_time_paf);
            tv4 = (TextView) view.findViewById(R.id.tv4_states_paf);
        }

        public void setData(problemExist obj) {
            tv1.setText(obj.getNote());//临时征用
            tv2.setText(obj.getExistDescribe());
            tv3.setText(TimeUtil.longToStr(obj.getFindTime()));
            tv4.setText(obj.getStates());
        }
    }
}
